import React from 'react'
import '../css/Borard.css'
import eventEmitter from '../event.js'

class Borard extends React.Component{
    constructor(props){
        super(props)
        this.state = {
            messages:[]
        }
    }


    componentDidMount(){
        eventEmitter.addListener('sendMessageTooBoard',(message)=>{
            console.log(message);
            this.state.messages.push(message)
            this.setState({
                message:this.state.messages
            })
        })
    }

    render(){
        return(
            <div className="borard_container">
                {
                    this.state.messages.map((item,index)=>{
                        return <div className="message" key={index}>
                            <h3>{item.content}</h3>
                            <h3>{item.date}</h3>
                        </div>
                    })
                }
            </div>
        )
    }
}


export default Borard